package com.lmscn.lms.api.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.lmscn.lms.api.util.JsonKit;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Czl on 2015/7/27.
 */
public class GetParaValidator extends Validator{

    Map<String,Object> dataMap = new HashMap<String,Object>();
    @Override
    protected void validate(Controller c) {
        if(c.getPara("studentId").equals("") || c.getPara("studentId") == null){
            dataMap.put("error_code",1);
            dataMap.put("msg","参数为空");
        }

    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson(JsonKit.mapToJson(dataMap,dataMap.size()));
    }
}
